﻿@model HXDNB.DAL.BuyOrder
@{decimal KoreaRate = (decimal)(new BuyParentBLL().GetByKey(int.Parse(Request["ParentID"])).KoreaRate ?? 1);}
<script type="text/javascript">

    $(function () {
        $("#ToAllPrice").click(function () {
            var Num = $("#Num").val() ? parseInt($("#Num").val()) : 0;
            var Price = $("#Price").val() ? parseFloat($("#Price").val()) : 0;
            var ExpressPrice = $("#ExpressPrice").val() ? parseFloat($("#ExpressPrice").val()) : 0;
            var OtherPrice = $("#OtherPrice").val() ? parseFloat($("#OtherPrice").val()) : 0;
            $("#AllPrice").val((Num * Price + ExpressPrice + OtherPrice).toFixed(2));
        });
        $("#ToKRate").click(function () {
            var OrgPrice = $("#ProductID option:selected").attr("OriginalPrice");
            var result = OrgPrice * $("#Discount").val();
            $("#KPrice").html(result);
            $("#Price").val((result / "@KoreaRate").toFixed(2));
        });
        $("#ProductID").change(function () {
            var OrgPrice = $("#ProductID option:selected").attr("OriginalPrice");
            $("#OriginalPrice").html(OrgPrice);
        }).change();
    });
</script>
<div class="widget-content">
    <div class="widget-box">
        <div class="widget-title">
            <span class="icon"><i class="icon-align-justify"></i></span>
            <h5>
                填写产品信息</h5>
        </div>
        <div class="widget-content nopadding">
            @if (IsPost == false && Request["result"] != null)
            {
                if (Request["result"] == "Y")
                {
                <div class="alert alert-success" style="margin-bottom: 0px;">
                    <a class="close" data-dismiss="alert" href="#">×</a>
                    <h4 class="alert-heading">
                        保存成功!</h4>
                    您的信息已经成功录入,你可以继续添加或者返回查看信息列表.
                </div>
                }
                else
                {
                <div class="alert alert-error" style="margin-bottom: 0px;">
                    <a class="close" data-dismiss="alert" href="#">×</a>
                    <h4 class="alert-heading">
                        保存失败!</h4>
                    如确认您的数据填写无误,请联系管理员或查看错误日志.
                </div>
                }
            }
            <form action="@Url.Action("Info", "BuyOrder", new { id = Request.QueryString["id"], ParentID = Request.QueryString["ParentID"] })" method="post" class="form-horizontal" enctype="multipart/form-data" >
            <div class="widget-content tab-content">
                <div id="tab1" class="tab-pane active">
                    <div class="control-group">
                        <label class="control-label">
                            进货产品:</label>
                        <div class="controls">
                            <div class="span6">
                                <select id="ProductID" name="ProductID">
                                    @foreach (var item in new ProductBLL().GetList())
                                    {
                                        <option value="@item.ID" OriginalPrice="@item.Price" @Html.Raw(item.ID == Model.ProductID ? "selected=\"selected\"" : "")>@(item.ProductName + " [₩:" + item.Price + "]")</option>
                                    }
                                </select>
                                <span class="help-block">请选择进货产品</span>
                            </div>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            出货时间:</label>
                        <div class="controls">
                            @Html.TextBoxFor(i => i.ShipTime, new Dictionary<string, object>() { { "class", "datepicker span3" }, { "data-date-format", "yyyy-mm-dd" } })
                            <span class="help-block">请选择出货时间</span>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            发货时间:</label>
                        <div class="controls">
                            @Html.TextBoxFor(i => i.SendTime, new Dictionary<string, object>() { { "class", "datepicker span3" }, { "data-date-format", "yyyy-mm-dd" } })
                            <span class="help-block">请选择发货时间</span>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            收货时间:</label>
                        <div class="controls">
                            @Html.TextBoxFor(i => i.ReceivedTime, new Dictionary<string, object>() { { "class", "datepicker span3" }, { "data-date-format", "yyyy-mm-dd" } })
                            <span class="help-block">请选择收货时间</span>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            进货数量:</label>
                        <div class="controls">
                            @Html.TextBoxFor(i => i.Num, new { @class = "span6", q = "q", @int = "int" })
                            <span class="help-block">请填写进货数量</span>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            进货折扣:</label>
                        <div class="controls">
                            @Html.TextBoxFor(i => i.Discount, new { @class = "span6", q = "q", money = "money" })
                            <span class="help-block">请填写进货折扣<font color="red">[例：0.95]</font></span>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            产品原价:</label>
                        <div class="controls">
                            <b id="OriginalPrice" style="color: Green">0</b>₩
                            <br />
                            <span class="help-block">当前选中产品韩国原价</span>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            进货单价:</label>
                        <div class="controls">
                            @Html.TextBoxFor(i => i.Price, new { @class = "span6", q = "q", money = "money" })
                            <span class="help-block">请填写进货单价</span>
                            <!---->
                            <span class="help-block">
                                <input id="ToKRate" class="btn btn-success btn-mini" style="color: White" type="button"
                                    value="计算单价" />
                                <font color="red"><b>[单价=韩币单价(产品原价×折扣)<span id="KPrice">0</span>/ 汇率(@KoreaRate)]</b></font></span>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            快递费用:</label>
                        <div class="controls">
                            @Html.TextBoxFor(i => i.ExpressPrice, new { @class = "span6", money = "money" })
                            <span class="help-block">请填写快递费用</span>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            其他费用:</label>
                        <div class="controls">
                            @Html.TextBoxFor(i => i.OtherPrice, new { @class = "span6", money = "money" })
                            <span class="help-block">请填写其他费用</span>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            总价:</label>
                        <div class="controls">
                            @Html.TextBoxFor(i => i.AllPrice, new { @class = "span6", money = "money" })
                            <span class="help-block">请填写进货总价</span> <span class="help-block">
                                <input id="ToAllPrice" class="btn btn-warning btn-mini" style="color: White; border-color: #faa732"
                                    type="button" value="计算总价" />
                                <font color="red"><b>[总价=进货数量×进货单价+快递费用+其他费用]</b> </font></span>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            快递单号:</label>
                        <div class="controls">
                            @Html.TextBoxFor(i => i.Express, new { @class = "span6" })
                            <span class="help-block">请输入快递单号<font color="green">[例：中通(2054621548245)]</font></span>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            备注:</label>
                        <div class="controls">
                            @Html.TextAreaFor(i => i.Remarks, new { @class = "span6", rows = "4" })
                            <span class="help-block">请输入产品备注 [最多输入4000个字符]</span>
                        </div>
                    </div>
                </div>
                <div class="form-actions">
                    @Html.HiddenFor(i => i.State)
                    @Html.HiddenFor(i => i.Createtime)
                    <button id="Save" type="submit" class="btn btn-success" onclick="return checkfrom()"
                        style="width: 100px">
                        @Html.Raw(string.IsNullOrWhiteSpace(Request.QueryString["id"]) ? "添 加" : "修改")
                    </button>
                    <a href="@Url.Action("List", "BuyOrder")" class="btn btn-danger" style="width: 100px">
                        返 回</a>
                </div>
            </div>
            </form>
        </div>
    </div>
</div>
